using Game.Main.Model;

namespace Game.Component
{
	public class StethoscopeItem : HadRopeItem
	{
		private CharacterItem targetItem;

		public override void Init(ItemArchiveData data)
		{
			base.Init(data);
		}

		public override void ResetState()
		{
			base.ResetState();
			InitPlaceItem();
		}

		protected override void LateUpdate()
		{
			base.LateUpdate();
			UpdatePutBackAnim();
		}

		protected override void OnItemCompTriggerEnter(ColliderData collData)
		{
			base.OnItemCompTriggerEnter(collData);
			if (collData.trigger.type == ItemComponentTrigger.Type.Body && collData.trigger.owner.itemData.scriptType == 1)
			{
				ResetTargetItem();
				targetItem = (CharacterItem)collData.trigger.owner;
				base.PlayDragSound();
			}
		}

		protected override void OnItemCompTriggerExit(ColliderData collData)
		{
			base.OnItemCompTriggerExit(collData);
			if (targetItem != null && collData.trigger.type == ItemComponentTrigger.Type.Body && collData.trigger.owner.itemData.scriptType == 1 && collData.trigger.owner == targetItem)
			{
				ResetTargetItem();
			}
		}

		protected override void PlayDragSound()
		{
		}

		private void ResetTargetItem()
		{
			if (targetItem != null)
			{
				targetItem = null;
				StopDragSound();
			}
		}

		public override void TouchDown(TouchEventData touchEventData)
		{
			base.TouchDown(touchEventData);
			needBack = true;
		}

		public override void TouchMove(TouchEventData touchEventData)
		{
			base.TouchMove(touchEventData);
		}

		public override void TouchUp(TouchEventData touchEventData)
		{
			base.TouchUp(touchEventData);
			PutBackPlaceItem();
			ResetTargetItem();
		}

		public void PutBackPlaceItemImmediately()
		{
			if (placeItem != null)
			{
				if (parentItem != null)
				{
					parentItem.ReleaseAttachItem(this);
				}
				placeItem.AttachItem(this, DepthType.Front, AttachType.PlacePoint, true);
			}
		}
	}
}
